﻿<UserControl 
  x:Class="DemoApp.View.CustomerView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:vw="clr-namespace:DemoApp.View"
  HorizontalAlignment="Center"
  VerticalAlignment="Center"  
  Width="400"
  xmlns:app="clr-namespace:DemoApp"
  >
	<Grid Margin="4">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="6" />
			<ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>

		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="30" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="30" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="30" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="30" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="30" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>

		<Grid.Resources>
			<DataTemplate DataType="{x:Type ValidationError}">
				<TextBlock 
		  FontStyle="Italic"
		  Foreground="Red"
		  HorizontalAlignment="Right"
		  Margin="0,1"
		  Text="{Binding Path=ErrorContent}" 
		  />
			</DataTemplate>
		</Grid.Resources>

		<!-- CUSTOMER TYPE -->
		<Label 
	  Grid.Row="0" Grid.Column="0" 
	  Content="Customer _type:" 
	  HorizontalAlignment="Right"
	  Target="{Binding ElementName=customerTypeCmb}" 
	  />
		<ComboBox 
	  x:Name="customerTypeCmb"
	  Grid.Row="0" Grid.Column="2" 
	  ItemsSource="{Binding Path=CustomerTypeOptions, Mode=OneTime}"
	  SelectedItem="{Binding Path=CustomerType, Mode=TwoWay, ValidatesOnDataErrors=True, BindingGroupName=CustomerGroup}"
	  Validation.ErrorTemplate="{x:Null}"
	  />
		<ContentPresenter 
	  Grid.Row="1" Grid.Column="2"
	  Content="{Binding ElementName=customerTypeCmb, Path=(Validation.Errors).CurrentItem}"
	  />

		<!-- FIRST NAME-->
		<Label 
	  Grid.Row="2" Grid.Column="0" 
	  Content="First _name:" 
	  HorizontalAlignment="Right"
	  Target="{Binding ElementName=firstNameTxt}"
	  />
		<TextBox 
	  x:Name="firstNameTxt"
	  Grid.Row="2" Grid.Column="2" 
	  Text="{Binding Path=Customer.FirstName, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, BindingGroupName=CustomerGroup}" 
	  Validation.ErrorTemplate="{x:Null}"
	  />
		<ContentPresenter 
	  Grid.Row="3" Grid.Column="2"
	  Content="{Binding ElementName=firstNameTxt, Path=(Validation.Errors).CurrentItem}"
	  />

		<!-- LAST NAME-->
		<Label 
	  Grid.Row="4" Grid.Column="0" 
	  Content="_Last name:" 
	  HorizontalAlignment="Right"
	  Target="{Binding ElementName=lastNameTxt}" 
	  />
		<TextBox 
	  x:Name="lastNameTxt"
	  Grid.Row="4" Grid.Column="2" 
	  Text="{Binding Path=Customer.LastName, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, BindingGroupName=CustomerGroup}"
	  Validation.ErrorTemplate="{x:Null}"
	  />
		<ContentPresenter 
	  Grid.Row="5" Grid.Column="2"
	  Content="{Binding ElementName=lastNameTxt, Path=(Validation.Errors).CurrentItem}"
	  />

		<!-- E-MAIL-->
		<Label 
	  Grid.Row="6" Grid.Column="0" 
	  Content="E-_mail:" 
	  HorizontalAlignment="Right"
	  Target="{Binding ElementName=emailTxt}" 
	  />
		<TextBox 
	  x:Name="emailTxt"
	  Grid.Row="6" Grid.Column="2" 
	  Text="{Binding Path=Customer.Email, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, BindingGroupName=CustomerGroup}"
	  Validation.ErrorTemplate="{x:Null}"
	  />
		<ContentPresenter 
	  Grid.Row="7" Grid.Column="2"
	  Content="{Binding ElementName=emailTxt, Path=(Validation.Errors).CurrentItem}"
	  />

		<!-- TotalSales -->
		<Label 
	  Grid.Row="8" Grid.Column="0" 
	  Content="Total Sales:" 
	  HorizontalAlignment="Right"
	  Target="{Binding ElementName=emailTxt}" 
	  />
		<TextBox 
	  x:Name="totalSalesTxt"
	  Grid.Row="8" Grid.Column="2" 
	  Text="{Binding Path=TotalSales, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, BindingGroupName=CustomerGroup}"
	  Validation.ErrorTemplate="{x:Null}"
	  />
		<ContentPresenter 
	  Grid.Row="9" Grid.Column="2"
	  Content="{Binding ElementName=totalSalesTxt, Path=(Validation.Errors).CurrentItem}"
	  />

		<!-- SAVE BUTTON -->
		<Button 
	  Grid.Row="10" Grid.Column="2"
	  Command="{Binding Path=SaveCommand}"
	  Content="_Save"
	  HorizontalAlignment="Right"
	  Margin="4,2" 
	  MinWidth="60" 
	  />
	</Grid>
</UserControl>